<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.edu.service.*"%>
<%@ page import="com.edu.service.impl.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.edu.entity.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="x"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/grade.css">
</head>
<body>
<form id="form" method="post">
		<div id="myid1">
		<p>
			<img src="image/2.png"><span>学生管理系统</span>
		</p>
		<br>
		<ul>
			  <li><img src="image/6.png"><a href="ShowGrade.jsp">查看成绩</a></li><br><br><br>
		      <li><img src="image/8.png"><a href="log.jsp">退出登录</a></li><br><br><br>
		</ul>

	</div>
	<div id="myWork">
		<div id="myGrade1">
			<p>
				班级: <select name="gClass">
					<option>1年级1班</option>
					<option>1年级2班</option>
					<option>1年级3班</option>
					<option>1年级4班</option>
				</select>&nbsp;&nbsp;
				 姓名/电话: <input type="text" name="gName"><input type="button" value="搜索" id="SouSuo" onclick="showAction('GSouSuoServlet')">
				  
					 <input type="button" value="新增" id="myAdd" onclick="showAction('GradeAdd.jsp')">
					 <input type="button" value="批量删除" onclick="showAction('DelAllServlet')">
					 <input type="button" value="导入" id="myIn">
					 <input type="button" value="导出" id="myOut">
			</p>
		</div>
			<table>
				<tr>
					<td><input type="checkbox" id="chec" onclick="delAll()"></td>
					<td>学生序号</td>
					<td>考试名称</td>
					<td>姓名</td>
					<td>班级</td>
					<td>学号</td>
					<td>语文</td>
					<td>数学</td>
					<td>英语</td>
					<td>操作</td>
				</tr>
				<%
				request.setCharacterEncoding("UTF-8");
		        Object obj=request.getAttribute("list");
		        if(obj==null){
		        	 UserService userservice=new UserServiceimpl();
		        	 List<Grade> grade=userservice.gradeSelect();
		             request.setAttribute("list", grade);
		        }
				%>
				<x:forEach items="${list }" var="grade" varStatus="status">
					<x:choose>
						<x:when test="${status.count%2==0 }">
							<tr style="background-color: #ccc;">
								<td><input type="checkbox" name="checkBox" value="${grade.gId }"></td>
								<td>${grade.gId }</td>
								<td>${grade.gPaterName }</td>
								<td>${grade.gName }</td>
								<td>${grade.gClass }</td>
								<td>${grade.gNum }</td>
								<td>${grade.gChinese }</td>
								<td>${grade.gMath }</td>
								<td>${grade.gEnglish }</td>
								<td>
									
									<a href="GradeAll.jsp?gId=${grade.gId }&gPaterName=${grade.gPaterName }&gName=${grade.gName }&gClass=${grade.gClass }&gNum=${grade.gNum }&gChinese=${grade.gChinese }&gMath=${grade.gMath }&gEnglish=${grade.gEnglish }" id="bY">编辑</a>
									<a href="GradeServlet?gId=${grade.gId }" id="Delete">删除</a>
								</td>
							</tr>
						</x:when>
						<x:otherwise>
							<tr>
								<td><input type="checkbox" name="checkBox" value="${grade.gId }"></td>
								<td>${grade.gId }</td>
								<td>${grade.gPaterName }</td>
								<td>${grade.gName }</td>
								<td>${grade.gClass }</td>
								<td>${grade.gNum }</td>
								<td>${grade.gChinese }</td>
								<td>${grade.gMath }</td>
								<td>${grade.gEnglish }</td>
								<td>
									<a href="GradeAll.jsp?gId=${grade.gId }&gPaterName=${grade.gPaterName }&gName=${grade.gName }&gClass=${grade.gClass }&gNum=${grade.gNum }&gChinese=${grade.gChinese }&gMath=${grade.gMath }&gEnglish=${grade.gEnglish }" id="bY">编辑</a>
									<a href="GradeServlet?gId=${grade.gId }" id="Delete">删除</a>
							   </td>
							</tr>
						</x:otherwise>
					</x:choose>

				</x:forEach>
			</table>
	</div>

</form>
	

</body>
<script>
     function $(id){
    	 return document.getElementById(id);
     }
    function showAction(url){
    	$("form").action=url;
    	$("form").submit();
    }
    function delAll(){
    	var s=document.getElementsByName("checkBox");
    	for(var i=0;i<s.length;i++){
    		s[i].checked=$("chec").checked;
    	}
    }
</script>
</html>